#include <iostream>
#include <vector>
#include <queue>

using namespace std;

const int N = 110;

int n;
int x, y;
vector<int> edges[N];
bool st[N];

int fa[N]; // fa[i]表示i结点的父亲
int dist[N]; //dis[i]表示i到x的最短距离

//深度
int dfs(int u)
{
	int ret = 0; // 所有孩子结点中深度的最大值
	for(auto v : edges[u])
	{
		ret = max(ret, dfs(v));
	}

	return ret + 1;
}

//宽度
int bfs()
{
	queue<int> q;
	q.push(1);

	int ret = 0;
	while(q.size())
	{
		int sz = q.size();
		ret = max(ret, sz);

		//每次出一层
		while(sz--)
		{
			int u = q.front(); q.pop();

			for(auto v : edges[u])
			{
				q.push(v);
			}
		}
	}

	return ret;
}



int main()
{
	cin >> n;
	for(int i = 1; i < n; i++)
	{
		int a, b; cin >> a >> b;
		//a是b的父结点
		edges[a].push_back(b);
		fa[b] = a;
	}

	//深度
	cout << dfs(1) << endl;

	//宽度
	cout << bfs() << endl;

	//求距离
	cin >> x >> y;
	while(x != 1) 
	{
		dist[fa[x]] = dist[x] + 1;
		x = fa[x];
	}

	int len = 0;
	while(y != 1 && !dist[y])
	{
		y = fa[y];
		len++;
	}
	cout << dist[y] * 2 + len << endl;

	return 0;
}


